﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Ceremony.Views.CeremonyListView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure"
    xmlns:commoncontrols="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Controls;assembly=StockholmsStad.Windows.UI.Infrastructure">
    <UserControl.Resources>
        <converters:DateTimeToDateString x:Key="DateTimeToDateString" />
        <converters:DateTimeToHourMinuteString x:Key="HourConverter" />
    </UserControl.Resources>

    <GroupBox Header="Sök ceremoni" Margin="5,5,5,5">

        <Grid Margin="5, 5, 10, 5" ShowGridLines="False">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="10" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>

            <!-- Search form -->
            <Label x:Name="lblDate" Content="Datum:" Grid.Row="0" Grid.Column="0" />
            <Label x:Name="lblMinister" Content="Förrättare" Grid.Row="0" Grid.Column="3" />

            <commoncontrols:DateTimePicker x:Name="dtpDateFrom" Grid.Row="1" Grid.Column="0" Margin="0,0,5,0" />
            <Polyline Points="0,20 0,20 10,0" Stroke="Gray" StrokeThickness="1" Grid.Row="1" Grid.Column="1" Margin="0,0,5,0" VerticalAlignment="Center" />            
            <commoncontrols:DateTimePicker x:Name="dtpDateTo" Grid.Row="1" Grid.Column="2" Margin="0,0,5,0" />

            <ComboBox x:Name="cbMinister" Text="" Height="22" Width="140" Grid.Row="1" Grid.Column="3" Margin="0,0,5,0" 
                      ItemsSource="{Binding}" DisplayMemberPath="FullName" />

            <ListBox x:Name="rbListCeremonyTypes" Style="{DynamicResource HorizontalRadioButtonList}" 
                     ItemsSource="{Binding}" Grid.Row="1" Grid.Column="4" Margin="0,0,5,0" DisplayMemberPath="Name">            
            </ListBox> <!-- SelectedValue="{Binding CeremonyType}"  //ItemsSource="{Binding Source={StaticResource CeremonyTypes}}"-->
            
            <Button x:Name="btnSearch" Content="Sök" Grid.Row="1" Grid.Column="5" VerticalAlignment="Center" />

            <!-- Search result list -->
            <ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" 
                          Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="6" Margin="0, 5, 5, 0">
                <StackPanel Orientation="Vertical">

                    <ListView x:Name="listViewOrdinaryCeremony" MinHeight="100" MaxHeight="200" ItemsSource="{Binding}"  
                              SelectionChanged="listviewCeremony_SelectionChanged">
                        <ListView.View>
                            <GridView ColumnHeaderContainerStyle="{DynamicResource GridViewColumnHeaderStyle1}" AllowsColumnReorder="False">
                                <GridView.Columns>
                                    <GridViewColumn Header="Datum" DisplayMemberBinding="{Binding Path=Date, Converter={StaticResource DateTimeToDateString}}" />
                                    <GridViewColumn Header="Förrättare" DisplayMemberBinding="{Binding Path=MinisterNames}" />
                                    <GridViewColumn Header="Vik. förrättare" DisplayMemberBinding="{Binding Path=TempMinisterNames}" />
                                    <GridViewColumn Header="Bokade" DisplayMemberBinding="{Binding Path=BookedTimeBlocks}" />
                                    <GridViewColumn Header="Lediga" DisplayMemberBinding="{Binding Path=AvailableTimeBlocks}" />
                                    <GridViewColumn Header="Kö" DisplayMemberBinding="{Binding Path=Queue}" Width="50" />
                                </GridView.Columns>
                            </GridView>
                        </ListView.View>
                    </ListView>
                    
                    <ListView x:Name="listViewIndividualCeremony" MinHeight="100" MaxHeight="200" ItemsSource="{Binding}" SelectionChanged="listviewCeremony_SelectionChanged">
                        <ListView.View>
                            <GridView ColumnHeaderContainerStyle="{DynamicResource GridViewColumnHeaderStyle1}" AllowsColumnReorder="False">
                                <GridView.Columns>
                                    <GridViewColumn Header="Datum" DisplayMemberBinding="{Binding Path=Date, Converter={StaticResource DateTimeToDateString}}"></GridViewColumn>
                                    <GridViewColumn Header="Förrättare" DisplayMemberBinding="{Binding Path=Minister.FullName}"></GridViewColumn>
                                    <GridViewColumn Header="Vik. förrättare" DisplayMemberBinding="{Binding Path=TempMinister.FullName}"></GridViewColumn>
                                </GridView.Columns>
                            </GridView>
                        </ListView.View>
                    </ListView>

                </StackPanel>
            </ScrollViewer>
            
            <GroupBox Grid.Column="7" Grid.RowSpan="4" Header="Lediga tider" Margin="5,5,5,5" Padding="5,5,5,5">
                <ListView x:Name="lvFreeTimes" VerticalAlignment="Top" MinHeight="140" MaxHeight="140"
                      ItemsSource="{Binding}"
                      ScrollViewer.HorizontalScrollBarVisibility="Disabled" Width="70">
                    <ListView.View>
                        <GridView>
                            <GridViewColumn DisplayMemberBinding="{Binding StartDateTime, Converter={StaticResource HourConverter}}" Width="70">
                                <GridViewColumn.Header>
                                    <GridViewColumnHeader Padding="5,0,0,0" Content="Tid" HorizontalContentAlignment="Left"/>
                                </GridViewColumn.Header>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>
            </GroupBox>

        </Grid>

    </GroupBox>

</UserControl>
